package com.kwlt;

import java.util.HashMap;

import java.util.List;
import java.util.Map;
import java.util.Set;

import redis.clients.jedis.Jedis;

public class TestRedis {
	public static void main(String[] args) {
		
		Jedis jedis = new Jedis("60.28.200.160");
		TestRedis test = new TestRedis();
		/*jedis.hset("user:admin", "admin", "admin");
		jedis.hset("user:admin", "password", "1234");
		jedis.hset("user:admin", "password1", "1234");
		Map<String, String> hgetAll = jedis.hgetAll("user:admin");
		for(String key:hgetAll.keySet()){
			System.out.print(key);
			System.out.print("=========");
			System.out.println(hgetAll.get(key));
		}*/
		test.setList(jedis);
	}
	
	public void setString(Jedis jedis){
		jedis.set("key", "hello jedis");
		String value = jedis.get("key");
		System.out.println(value);
	}
	
	public void setList(Jedis jedis){
		jedis.rpush("message", "message1");
		jedis.rpush("message", "message2");
		jedis.rpush("message", "message3");
		jedis.rpush("message", "message4");
		jedis.rpush("message", "message5");
		List<String> values = jedis.lrange("message", 0, 3);
		System.out.println(values);
	}
	
	public void setSet(Jedis jedis){
		jedis.sadd("myset", "1");
		jedis.sadd("myset", "1");
		jedis.sadd("myset", "2");
		jedis.sadd("myset", "3");
		Set<String> setValues = jedis.smembers("myset");
		System.out.println(setValues);
	}
	
	
}
